// 方式一
//
// 时间：112ms - 24.29%
var isUgly = function(num) {
  if (num < 1) return false;
  const map = [5, 3, 2];
  for (let n = 0; n < map.length; n++) {
    let flag = true;
    const element = map[n];
    while (flag) {
      const next = num / element;
      if (Number.isInteger(next)) {
        break;
      }
      num = next;
    }
  }
  return num === 1;
};
console.log(isUgly(6));
